<% include ../public/page_header.html %>

    <!--
        列表展示
    -->
    <div class="panel panel-default">
        <div class="panel-heading">
            <a href="/<%=pathname%>/product/add" class="btn btn-primary">增加菜品</a>
        </div>
        <div class="table-responsive">
            <table class="table table-bordered">
                <thead>
                    <tr class="th">
                        <th>菜品名称</th>
                        <th>菜品分类</th>
                        <th>菜品图片</th>
                        <th>增加时间</th>
                        <th class="text-center">排序</th>
                        <th class="text-center">推荐</th>
                        <th class="text-center">热销</th>
                        <!-- <th class="text-center">状态</th> -->

                        <th class="text-center">操作</th>
                    </tr>
                </thead>
                <%for(var i=0;i<list.length;i++){%>
                    <tr>

                        <td>
                            <%=list[i].title%>
                        </td>
                        <td>
                            <%=list[i].ProductCate[0].title%>
                        </td>
                        <td><img width="80" src="<%=list[i].img_url%>" alt="" srcset=""></td>

                        <td>
                            <%=list[i].addTime%>
                        </td>

                        <td class="text-center">
                            <%=list[i].sort%>
                        </td>

                        <td class="text-center touch" data-id="<%=list[i].id%>" data-query="is_best"  data-state="<%=list[i].is_best%>">

                            <%if(list[i].is_best==1){%>

                                <img src="/public/admin/images/yes.gif" />

                                <%}else{%>
                                    <img src="/public/admin/images/no.gif" />
                                    <%}%>
                        </td>

                        <td class="text-center touch" data-id="<%=list[i].id%>" data-query="is_hot" data-state="<%=list[i].is_hot%>">

                            <%if(list[i].is_hot==1){%>

                                <img src="/public/admin/images/yes.gif" />

                                <%}else{%>
                                    <img src="/public/admin/images/no.gif" />
                                    <%}%>
                        </td>

                        <!-- <td class="text-center touch" data-id="<%=list[i].id%>" data-query="status" data-state="<%=list[i].status%>">

                            <%if(list[i].status==1){%>

                                <img src="/public/admin/images/yes.gif" />

                                <%}else{%>
                                    <img src="/public/admin/images/no.gif" />
                                    <%}%>
                        </td> -->

                        <td class="text-center" >

                            <a href="/<%=pathname%>/product/edit?id=<%=list[i].id%>">编辑</a>

                            <a class="delete" href="/<%=pathname%>/product/del?id=<%=list[i].id%>">删除</a>
                        </td>
                    </tr>
                    <%}%>


            </table>

            <nav aria-label="Page navigation">
                <ul class="pagination">
              
                  <li><a href="/<%=pathname%>/product?page=1">1</a></li>
                  <li><a href="/<%=pathname%>/product?page=2">2</a></li>
                  <li><a href="/<%=pathname%>/product?page=3">3</a></li>
                  <li><a href="/<%=pathname%>/product?page=4">4</a></li>
                  <li><a href="/<%=pathname%>/product?page=5">5</a></li>
                
                </ul>
              </nav>
        </div>

    </div>
    </body>

    <script>
        $('.touch').click(function () {
            $.get(`/<%=pathname%>/touch?id=${$(this).attr('data-id')}&query=${$(this).attr('data-query')}&state=${$(this).attr('data-state')}`).then(x=>{
                var el=$(this).find("img");
                if(x.success == 1){
                    if(el.attr("src").indexOf("yes")!=-1){
						el.attr("src","/public/admin/images/no.gif");
					}else{
						el.attr("src","/public/admin/images/yes.gif");
					}
                }
            })
        })
    </script>

    </html>